<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p><strong>以下内容是通过异步请求获取的：</strong></p>
    <p id="demo"></p>
    <script>
        var xhr = new XMLHttpRequest();
        xhr.onload = function () {
            // 输出接收到的文字数据
            document.getElementById("demo").innerHTML=xhr.responseText;
        }
        xhr.onerror = function () {
            document.getElementById("demo").innerHTML="请求出错"
        }

        // 发起异步 GET请求
        xhr.open("GET","https://www.qq.com", true)
        xhr.send();
    </script>
</body>
</html>